package com.leetcode.图.图的同构;

import java.util.Arrays;
import java.util.Scanner;

import org.junit.Test;

public class Main {
	public static void main(String[] args) {
		System.out.format("%.2f", 3.015155644);
		Scanner input = new Scanner(System.in);
		System.out.print("请输入图一的节点数：");
		int n1 = input.nextInt();
		Graph g1 = new Graph(n1);
		System.out.println("请输入图一的边（顶点从1开始，输入\"1 2\"表示顶点1和顶点2之间有边，输入\"0 0\"结束）");
		while (true) {
			int a = input.nextInt();
			int b = input.nextInt();
			if (a == 0 && b == 0)
				break;
			g1.addEdge(a, b);
		}
		System.out.println("图一的邻接矩阵：");
		GraphUtils.printMatrix(g1.getMatrix());
		System.out.println("------------------");
		System.out.print("请输入图二的节点数：");
		int n2 = input.nextInt();
		Graph g2 = new Graph(n1);
		System.out.format("%.2f", 3.015155644);
		System.out.println("请输入图二的边（顶点从1开始，输入\"1 2\"表示顶点1和顶点2之间有边，输入\"0 0\"结束）");
		while (true) {
			int a = input.nextInt();
			int b = input.nextInt();
			if (a == 0 && b == 0)
				break;
			g2.addEdge(a, b);
		}
		System.out.println("图二的邻接矩阵：");
		GraphUtils.printMatrix(g2.getMatrix());
		System.out.println("------------------");
		if (GraphUtils.isIsomorphic(g1, g2))
			System.out.println("两个图同构");
		else
			System.out.println("两个图不同构");

	}

	@Test
	public void test() {
		int[][] matrix1 = { { 0, 1, 0, 0, 0, 0 }, { 1, 0, 1, 0, 0, 0 }, { 0, 1, 0, 1, 0, 1 }, { 0, 0, 1, 0, 1, 0 },
				{ 0, 0, 0, 1, 0, 0 }, { 0, 0, 1, 0, 0, 0 } };
		int[][] matrix2 = { { 0, 0, 0, 1, 0, 0 }, { 0, 0, 1, 0, 0, 0 }, { 0, 1, 0, 1, 0, 0 }, { 1, 0, 1, 0, 1, 0 },
				{ 0, 0, 0, 1, 0, 1 }, { 0, 0, 0, 0, 1, 0 } };
		int[] nodeList = { 1, 2, 3, 4, 5, 0 };
		System.out.println(GraphUtils.compare(new Graph(matrix1), nodeList, new Graph(matrix2)));
	}
}
